package com.abss.vote.service.impl;

import com.abss.vote.mapper.MpInFoMapper;
import com.abss.vote.model.MpInfo;
import com.abss.vote.service.MpInFoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MpInFoServiceImpl implements MpInFoService {

    @Autowired
    private MpInFoMapper mpInFoMapper;

    @Override
    public void updateMpInFo(MpInfo mpInfo) {
        //首先查询数据库是否存在
        int res = mpInFoMapper.ExistMpinfo(mpInfo);
        if(res>0){//存在修改
            mpInFoMapper.UpdateMpinfo(mpInfo);
        }else{//不存在添加
            mpInFoMapper.InsertMpinfo(mpInfo);
        }
    }

    @Override
    public MpInfo getMpInFoByServerId(String serverId) {
        return mpInFoMapper.getMpInFo(serverId);
    }
}
